package com.wjc.httpserver;

import java.net.UnknownHostException;

import socks.CProxy;
import socks.Socks5Proxy;

public class MySocks5Proxy extends Socks5Proxy {
	public MySocks5Proxy(CProxy p, String proxyHost, int proxyPort)
			throws UnknownHostException {
		super(p, proxyHost, proxyPort);
	}
	private int sucessCount = 0;//连续成功次数
	private int failCount = 0;//连续失败次数 
	
	public int getSucessCount() {
		return sucessCount;
	}
	public int getFailCount() {
		return failCount;
	}
	
	public void countResult(boolean result) {
		if( result ) {
			if( failCount > 0 ) {
				failCount = 0;
			}
			sucessCount ++;
		} else {
			if( sucessCount > 0 ) {
				sucessCount = 0;
			}
			failCount ++;
		}
	}
	
	
	public String toString() {
		return "proxy{" + this.proxyHost + "/"  + this.proxyIP + ":" + this.proxyPort + "}";
	}
}
